import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:get/get.dart';
import 'package:sainbainu/common/values/colors.dart';

import 'index.dart';
import 'widgets/widgets.dart';

class LiveRecordPage extends GetView<LiveRecordController> {
  const LiveRecordPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetBuilder<LiveRecordController>(
      builder: (_) {
        return Scaffold(
          appBar: AppBar(title: const Text("直播记录")),
          body: SafeArea(
            top: false,
            minimum: const EdgeInsets.only(bottom: 10),
            child: _buildBody(),
          ),
        );
      },
    );
  }

  // 主视图
  Widget _buildBody() {
    return ListView.separated(
      padding: const EdgeInsets.all(0),
      separatorBuilder: (context, index) {
        return _buildDivider();
      },
      itemCount: controller.state.recordList.length,
      itemBuilder: (context, index) {
        return ExpansionItem(
          item: controller.state.recordList[index],
        );
      },
    );
  }

  /// 分割线
  Widget _buildDivider() {
    return const Divider(
      height: 0,
      indent: 0,
      endIndent: 0,
      thickness: 0.5,
      color: AppColors.border,
    );
  }
}
